package top.icecola.community.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import top.icecola.community.domain.PageResponse;
import top.icecola.community.domain.User;
import top.icecola.community.service.UserService;

import java.io.IOException;
import java.util.List;

@Controller
public class HellloController {

    @Autowired
    private UserService userService;

    @GetMapping("/user")
    @ResponseBody
    public List<User> user(){
        List<User> userList = userService.selectAll();
        return userList;
    }
    @GetMapping("/users")
    @ResponseBody
    public PageResponse bookPage(Model model, @RequestParam("pageNum") Integer pageNum,
                                 @RequestParam("pageSize") Integer pageSize) throws IOException {
        PageResponse pageResponse = userService.userPage(pageNum, pageSize);
        return pageResponse;
    }
}
